package main.test.meituan;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class T1 {
    static int res=-1;
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int[] c=new int[n];
        List<Integer>[] lists=new List[n];
        for (int i = 0; i < lists.length; i++) {
            lists[i]=new ArrayList<>();
        }
        for (int i = 0; i < n; i++) {
            c[i] = sc.nextInt();
            for (int j = 0; j < c[i]*2; j++) {
                lists[i].add(sc.nextInt());
            }
        }
        int money=0;
        int en=0;
        dfs(0, lists, c, money, en, m);
        System.out.println(res);
    }
    public static void dfs(int n,List<Integer>[] lists,int[] c,int money,int en,int m){
        if (n==lists.length){
            res=Math.max(res,en);
            return;
        }
        for (int j = 0; j < c[n]; j++) {

            int i1 = lists[n].get(j*2);
            int i2 = lists[n].get(j*2+1);
            money+=i1;
            en+=i2;
            if (money<=m){
                dfs(n+1,lists,c,money,en,m);
            }
            money-=i1;
            en-=i2;
        }
    }
}
